package cn.smile.controller.core;

import cn.smile.bean.dto.core.SysNotPermissionDTO;
import cn.smile.bean.entity.core.SysNotPermission;
import cn.smile.business.core.ISysNotPermissionService;
import cn.smile.commons.response.MyResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;
import java.util.List;

/**
 * @author 10834
 */
@Slf4j
@RestController
@RequestMapping("api/permission")
public class PermissionController {

    @Resource
    private ISysNotPermissionService service;

    @GetMapping(value = "getUrlList")
    public MyResult<List<SysNotPermissionDTO>> getUrlList() {
        log.info("[PermissionController].[getUrlList] ------> Get Url List Start");
        List<SysNotPermissionDTO> list = service.getUrlList();
        log.info("[PermissionController].[getUrlList] ------> Get Url List End, list.size() = {}", CollectionUtils.isEmpty(list) ? null : list.size());
        return MyResult.OK(list);
    }

    @PostMapping(value = "addInfo")
    public MyResult<Boolean> addInfo(@RequestBody SysNotPermission permission) {
        log.info("[PermissionController].[creat] ------> Creat Data Info Start, permission = {}", permission);
        Boolean result = service.create(permission);
        log.info("[PermissionController].[creat] ------> Creat Data Info End, result = {}", result);
        return MyResult.OK(result);
    }
}
